﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace ConsoleApp6
{
    class Student : IComparable
    {
        public string Name { get; set; }
        public int Age { get; set; }

        public int NUM { get; set; }

        public char Sex { get; set; }
        public Student(string name, int age, int nUM, char sex)
        {
            Name = name;
            Age = age;
            NUM = nUM;
            Sex = sex;
        }

        public Student(string name, int num, int age)
        {
            Name = name;
            NUM = num;
            Age = age;
        }

        public override string ToString()
        {
            return $"名字:{Name} 学号：{NUM} 性别：{Sex} 年龄：{Age}";
        }



        public int CompareTo(object obj)
        {
            if (obj is Student)
            {
                //return this.Name.CompareTo(((Student)obj).Name);
                return this.Age.CompareTo(((Student)obj).Age);
            }
            else
            {
                throw new Exception("搞错了，不是Student扔进来干嘛。");
            }
        }
    }
}
